
const KEY = 'heima-token'
// 存
const setUserInfo = (UserInfo) => {
  let userInfoStr
  try {
    userInfoStr = JSON.stringify(UserInfo)
  } catch (error) {
    userInfoStr = ''
  }
  localStorage.setItem(KEY, userInfoStr)
}
// 取
const getUser = () => {
  let userInfo
  try {
    userInfo = JSON.parse(localStorage.getItem(KEY))
  } catch (error) {
    userInfo = {}
  }
  return userInfo
}
// 删
const removeUserInfo = () => {
  localStorage.removeItem(KEY)
}
export { setUserInfo, getUser, removeUserInfo }
